<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>属性选择器</title>
</head>
<body>

<style>
    a {
        float: left;
        /*display: block;*/
        height: 50px;
        width: 50px;
        border-radius: 10px;
        background: pink;
        text-align: center;
        color: gainsboro;
        text-decoration: none;
        margin-right: 5px;
        font: bold 20px/50px Arial;
    }

    /*
    a[属性名/属性值(可以为正则)]
    = 绝对等于
    *= 包含
    ^= 以..开发
    $= 以..结尾
    */

    /*1. 存在id属性的元素*/
    a[id] {
        color: red;
    }

    a[id=second] {
        color: orange;
    }

    /*2. class中有links的元素*/
    a[class*=links] {
        background: green;
    }

    /*3. href中以http开头的元素*/
    a[href^=http] {
        background: yellow;
    }

    /*4. href中以pdf结尾的元素*/
    a[href$=pdf] {
        background: cyan;
    }

</style>

<p>
    <a href="https://www.baidu.com" class="links item first" id="first">1</a>
    <a href="#" class="links item active" target="_blank" id="second">2</a>
    <a href="imgs/123.png" class="links item">3</a>
    <a href="imgs/456.jpg" class="links item">4</a>
    <a href="abc.pdf" class="links item">5</a>
    <a href="a.pdf" class="links item">6</a>
    <a href="abc.doc" class="links item">7</a>
    <a href="cd.doc" class="links item">8</a>
</p>

</body>
</html>